#include "main_window.h"
#include "ui_main_window.h"
#include <QtGui>
#include "hierarchical_menu_button.h"

main_window::main_window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::main_window)
{
    ui->setupUi(this);

    checkable_menu::tree tree;
    tree.add_node( { std::make_tuple("key_points", "points", 1, 0), std::make_tuple("key_radars", "radars", 1, 0), std::make_tuple("key_airdroms", "airdroms", 1, 0) } );

    tree.add_node( "key_points", { std::make_tuple("key_points1", "points1", 1, 0), std::make_tuple("key_points2", "points2", 11, 22), std::make_tuple("key_points3", "points3", 1, 0) } );
//    tree.add_node( "radars", { {"radars1", 0}, {"radars2", 0}, {"radars3", 0} } );

//    tree.add_node( "points1", { {"points11", 0}, {"points12", 0}, {"points13", 0} } );
//    tree.add_node( "points11", { {"points111", 0}, {"points112", 0}, {"points113", 0} } );
//    tree.add_node( "points111", { {"points111", 0}, {"points112", 0}, {"points113", 0} } );

    tree.print();

    centralWidget()->setLayout(new QVBoxLayout());
    hierarchical_menu_button *menu1 = new hierarchical_menu_button(tree, "objects", this);
    centralWidget()->layout()->addWidget(menu1);

    checkable_menu::tree t1;
    t1.add_node( { std::make_tuple("key_radars1", "radars1", 1, 0) } );
    menu1->add_menu("key_radars", t1);

//    checkable_menu::tree t2;
//    t2.add_node( { std::make_tuple("key_radars2", "radars2", 0) } );
//    menu1->add_menu("key_radars", t2);

    checkable_menu::tree t3;
    t3.add_node( {  std::make_tuple("key_radars3", "radars3", 55, 66) } );
    menu1->add_menu("key_radars", t3);

    menu1->set_checked("key_radars1", true);
//    menu1->set_checked("key_radars3", true);

//    qDebug() << menu1->has_key("key_radars") << menu1->has_key("key_radars3");

    checkable_menu::tree t4;
    t4.add_node( {  std::make_tuple("key_radars31", "radars31", 55, 66) } );
    menu1->add_menu("key_radars3", t4);

    menu1->set_enabled("key_radars31", false);
    menu1->set_checked("key_radars31", true);
}

main_window::~main_window()
{
    delete ui;
}

